<?
/**
*  咨询管理
*  2014/9/18
*/
include("database.php");

include("session.php");
require("ajax_base.php");

$db = new SimpleDB();
$table_name = "crm_info";
$action = $_GET['action'];

if($action == "del") {
	$db->doDelete($table_name, 'id='.$_GET['id']); 
	echo "ok";

}  else if($action == "list") {
	$condition = "1=1";
	$sql = "select id, content, post_time from $table_name where $condition order by id desc"; 
	echo to_grid_json($db, $sql, $dic_data, array("post_time"=>"blue_color_mapper"));

} else if($action == "get") {
	$sql = "select * from $table_name where id=".$_GET['id']; 
	$arr = $db->getOneRecordArray($sql);
	echo array_to_json($arr);

}  else if($action == "add") {
	unset($_POST['id']);
	$_POST['post_time'] = date("Y-m-d H:i:s");
	$db->doInsert($table_name, $_POST);
	echo 'ok';

} else if($action == "edit") {
	$id = $_POST['id'];
	unset($_POST['id']);
	$_POST['post_time'] = date("Y-m-d H:i:s");
	$db->doUpdate($table_name, $_POST, 'id='.$id);
	echo 'ok';

} 


?>